package druid;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.sql.Connection;
import java.util.Properties;

/**
 * @author tongchen
 * @create 2022-11-03 22:57
 */
public class DruidDemo {
    public static void main(String[] args) throws Exception {
        //1.导入jar包
        //2.定义配置文件
        //3.加载配置文件
        Properties properties = new Properties();
       properties.load(new FileInputStream("jdbcdemo/src/main/java/druid"));
       // System.out.println(System.getProperty("user.dir"));
        //4.获取连接池对象
        DataSource dataSource = DruidDataSourceFactory.createDataSource(properties);
        //5.建立连接
        Connection connection = dataSource.getConnection();
        System.out.println(connection);
    }
}
